#include<bits/stdc++.h>//I love CCF
using namespace std;
const int N=100005;
int t,n,m,L,V,ans,maxn;
int d[N],v[N],a[N],p[N];
bool vis[N];
void putin(){
    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++){
        cin>>d[i]>>v[i]>>a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>p[i];
    }
}

int get_speed(int d,int v,int a){
    double g=sqrt(v*v+2*a*d);
    if(int(g)<g)    return(int(g)+1);
    else    return (int(g));
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
    vector<int> g[N];
    ans=0;
        putin();
        for(int i=1;i<=n;i++){
        bool f=false;
            for(int j=1;j<=m;j++){
                if(d[i]>p[j])   continue;
                int xxt=get_speed(p[j]-d[i],v[i],a[i]);
                if(xxt<=0)   break;
                else{
                    if(xxt>V){
                        f=true;
                        break;
                    }
                    continue;
                }
            }
            if(f)   ans++;
        }
        cout<<ans<<" "<<ans<<endl;
        maxn=0;
    }
    return 0;
}// No,acuallly I...
